package com.yb.designpattern.action.observer;

import java.util.ArrayList;
import java.util.List;

public class ConcreteSubject implements Subject{
	private int state;
	private List<Observer> observers = new ArrayList<Observer>();
	public void registObserver(Observer o){
		observers.add(o);
	}
	public void removeObserver(Observer o){
		observers.remove(o);
	}
	public void notifyObservers(){
		for(Observer observer:observers){
			observer.update(state);
		}
	}
	public void change(int i) {
		this.state = i;
		notifyObservers();
	}
}
